<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<div class="modal fade" id="ocean-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 1000px; height: auto">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <c:choose>
                    <c:when test="${entity.id != null && entity.id!= ''}">
                        <h4 class="modal-title">编辑监管部门</h4>
                    </c:when>
                    <c:otherwise>
                        <h4 class="modal-title">新增监管部门</h4>
                    </c:otherwise>
                </c:choose>
            </div>
            <div class="modal-body">
                <div class=" form">
                    <form class="cmxform form-horizontal tasi-form" id="supervisionDept_from" method="post"
                          data-url="resources/entity"
                          data-class="com.ocean.billboard.entity.SupervisionDept">
                        <input type="hidden" id="entity_id" name="id" value="${entity.id}">
                        <div class="form-group">
                            <label for="name" class="control-label col-lg-2">名称 </label>
                            <div class="col-lg-10">
                                <input class="form-control" id="name" name="name" type="text" placeholder="名称"
                                       value="${entity.name}"
                                       required/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="address" class="control-label col-lg-2">地址 </label>
                            <div class="col-lg-10">
                                <input class="form-control" id="address" name="address" type="text" placeholder="地址"
                                       value="${entity.address}"
                                       required/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="contactName" class="control-label col-lg-2">联系人 </label>
                            <div class="col-lg-10">
                                <input class="form-control" id="contactName" name="contactName" type="text"
                                       placeholder="联系人"
                                       value="${entity.contactName}"
                                       required/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="contact" class="control-label col-lg-2">联系方式 </label>
                            <div class="col-lg-10">
                                <input class="form-control" id="contact" name="contact" type="text" placeholder="手机号码"
                                       value="${entity.contact}"
                                       required maxlength="11" minlength="11"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-lg-offset-2 col-lg-10">
                                <button class="btn btn-success" type="button" onclick="validateName()">Save
                                </button>
                                <button class="btn btn-default" type="button" data-dismiss="modal">Cancel</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="application/javascript">
    var validator = $("#supervisionDept_from").validate();
    function validateName() {
        var name = $('#name').val().trim();
        request.post("resources/supervisionDept/validateName", {name: name}, function (data) {
            if (data.length > 0){
                alert("*该名称已在 监管部门界面 存在记录，不可重复~");
                return false;
            }else {
                formSubmit(validator);
            }
        })
    }
</script>
